import request from '@/utils/request'

// 获取试卷列表
export function getPaperList(query) {
  return request({
    url: '/admin-api/papers',
    method: 'get',
    params: query
  })
}

// 获取试卷详情
export function getPaperDetail(query) {
  return request({
    url: '/admin-api/papers/' + query,
    method: 'get'
  })
}

// 新建试卷
export function createPaper(data) {
  return request({
    url: '/admin-api/papers',
    method: 'post',
    data
  })
}

// 更新试卷
export function updatePaper(id, data) {
  return request({
    url: '/admin-api/papers/' + id,
    method: 'put',
    data
  })
}

// 上传试卷封面
export function uploadPaperCover(data) {
  return request({
    url: '/admin-api/papers/image',
    method: 'post',
    data
  })
}

// 获取试卷下的试题列表
export function getPaperQuestion(id, query) {
  return request({
    url: '/admin-api/papers/questions/' + id,
    method: 'get',
    params: query
  })
}

// 更新试卷下的试题
export function updatePaperQuestion(id, data) {
  return request({
    url: '/admin-api/papers/questions/' + id,
    method: 'post',
    data
  })
}

// 移除试卷试题
export function removePaperQuestion(id, data) {
  return request({
    url: '/admin-api/papers/questions/' + id,
    method: 'DELETE',
    data
  })
}

// 试卷发布
export function publishPaper(id) {
  return request({
    url: '/admin-api/papers/published/' + id,
    method: 'post'
  })
}
